package com.ykt.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.InterceptorStack;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.ykt.content.Content;
import com.ykt.model.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogInterceptor extends InterceptorStack {
    private final static Logger LOGGER = LoggerFactory.getLogger("com.ykt.operator.log");


    @Override
    public void config() {
        addInterceptors(new LoginAdminInterceptor(), new Interceptor() {
            @Override
            public void intercept(Invocation ai) {
                Controller c = ai.getController();
                Admin admin = c.getSessionAttr(Content.SESSION_LOGIN_USER);
                LOGGER.info("管理员：{%s} 请求 {%s},", admin.getInt("id"), ai.getActionKey());

                ai.invoke();
            }
        });
    }

}
